package com.yxr.affairs.utils;


import android.text.TextUtils;

import com.yxr.affairs.MyApplication;

public class UserInfo1 {

    private static final String SYHBH = "cP_YHBH"; //用户编号
    private static final String SYHMM = " cP_YHCZKL"; //用户密码


    /**
     * 获取编号
     */
    public static String getUsername(){
        return MyApplication.cfg.getStringShareData(SYHBH);
    }

    /**
     * 获取密码
     */
    public static String getSessionid(){
        return MyApplication.cfg.getStringShareData(SYHMM);
    }

    /**
     * 保存用户基本信息
     */
    public static void setUserInfo(String sYHBH, String sYHMM){
        if (sYHBH != null) {
            MyApplication.cfg.storeShareDataWithCommit(SYHBH, sYHBH);
        }
        if (sYHMM != null){
            MyApplication.cfg.storeShareDataWithCommit(SYHMM, sYHMM);
        }

        MyApplication.cfg.commit();
    }
    /**
     * 退出登录
     */
    public static void exitLogin(){
        MyApplication.cfg.storeShareDataWithCommit(SYHBH, "");
        MyApplication.cfg.storeShareDataWithCommit(SYHMM, "");
        MyApplication.cfg.commit();
    }

    /**
     * 判断是否登录状态
     */
    public static boolean isLogin(){
        if (!TextUtils.isEmpty(MyApplication.cfg.getStringShareData(SYHBH))&&
                !TextUtils.isEmpty(MyApplication.cfg.getStringShareData(SYHMM))){
            return true;
        }
        return false;
    }

}
